package com.jmag.nop.orderweb.controller;


import com.jmag.nop.orderapi.domain.TOrder;
import com.jmag.nop.orderapi.service.TOrderService;
import com.jmag.nop.service.common.annotation.ApiMapping;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author jmag
 */
@Api(tags = "订单接口")
@RestController
public class TOrderController {

    @Autowired
    private TOrderService orderServiceImpl;

    /**
     * 创建订单
     * @param order
     * @return
     */
    //@GetMapping("create")
    @ApiOperation(value="创建订单信息", notes = "创建订单信息")
    @ApiMapping(value="order.create",version = "1.0")
    public TOrder create10(TOrder order){

        //Assert.notNull(order.getUserId(), "UserId must not be null");
        //Assert.notNull(order.getProductId(), "ProductId must not be null");
        //Assert.notNull(order.getCount(), "Count must not be null");
        //Assert.notNull(order.getMoney(), "Money must not be null");

        orderServiceImpl.create(order);

        return order;//"Create order success";

    }

    /**
     * 创建订单
     * @param order
     * @return
     */
    //@GetMapping("create")
    @ApiOperation(value="创建订单信息", notes = "创建订单信息")
    @ApiMapping(value="order.create",version = "1.1")
    public TOrder create11(TOrder order){

        //Assert.notNull(order.getUserId(), "UserId must not be null");
        //Assert.notNull(order.getProductId(), "ProductId must not be null");
        //Assert.notNull(order.getCount(), "Count must not be null");
        //Assert.notNull(order.getMoney(), "Money must not be null");

        orderServiceImpl.create(order);

        return order;//"Create order success";

    }

    /**
     * 创建订单
     * @param order
     * @return
     */
    //@GetMapping("create")
    @ApiOperation(value="创建订单信息", notes = "创建订单信息")
    @ApiMapping(value="order.create",version = "1.2")
    public TOrder create12(TOrder order){

        //Assert.notNull(order.getUserId(), "UserId must not be null");
        //Assert.notNull(order.getProductId(), "ProductId must not be null");
        //Assert.notNull(order.getCount(), "Count must not be null");
        //Assert.notNull(order.getMoney(), "Money must not be null");

        orderServiceImpl.create(order);

        return order;//"Create order success";

    }

    /**
     * 查询订单
     * @param order
     * @return
     */
    @PostMapping("order.query")
    @ApiOperation(value="查询订单信息", notes = "查询订单信息")
    @ApiMapping(value="order.query")
    public TOrder query(TOrder order){

        //业务查询忽略

        return order;

    }
}
